<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@taglib prefix="m" uri="/cutm_tags"%>

<html>
<head>
<title>撰写稿件</title>
<script type="text/javascript">
$(document).ready(function(){
	$("#myform").vaildAjax(function(data){
		$('.btnGroup').remove();
		if(data==null || data==''){
			BaseJs.alert('审核成功');
			$('#save').hide();
			$('#edit').hide();
		}else{
			BaseJs.alert($.trim(data).substring(4));
		}
	});
	var options = {selectAllText: '全选',noneSelected:'请选择联合报道记者',
			oneOrMoreSelected:'已选%人',listHeight:'200'};
	$('#selectType').multiSelect(options,function(){
		var list ='';
		$('#reporters LABEL.checked').each(function(){
			var txt = $(this).text();
			if(txt!='全选')
			list+='<p class="">'+txt+'</p>';
		});
		$('#allReporters').html(list);
		$('input[name="lhjz"]').val($('input[class=selectType]').checkbox());
		
	});
	$('#allReporters').html($('input[name="lhbdjzName"]').val());
	$('input[name="lhjz"]').val($('input[name="lhbdjzId"]').val());	

	//加入历史审核记录（分解显示List auditRecd）
	$('a.delimage').live('click',function(){
		var id = $($(this)[0]).attr('value');
		var mid = $('input[name="manuscript.id"]').val();
		$.urlAjax('manuscript/EditManuscript!delRefrence?images='+id+'&manuscript.id='+mid,function(data){
			if(data=='OK'){
				$('#li'+id).remove();
				BaseJs.alert('删除成功.');
			}
		});
	});
	
	$('a.viewBig').click(function(e,obj){
		var ori = $($(this)[0].parentNode.innerHTML).find('img')[0].src;
		var now = ori.replace('_128.','.');
		window.open(now);
	});
});

function killManuSc(){
	var id=$('input[name="manuscript.id"]').val();
	if(BaseJs.confirm('确定毙稿吗？毙稿后,稿件将永不录用!')){
		var data = {};
			data['manuscript.id'] = id;
			data['manuScAudit.remark'] =  $('#msaRemark').val();
		$.urlAjaxData('manuscript/EditManuscript!killMas',data,function(data){
			if(data=='Ok'){
				BaseJs.toAction('manuscript/ListManuscript');
			}else{
				$.alert(data);
			}
		});
	}
}

function returnToApp(){
	var id=$('input[name="manuscript.id"]').val();
	if(BaseJs.confirm('确定返还给记者吗？')){
		var data = {};
			data['manuscript.id'] = id;
			data['manuScAudit.remark'] =  $('#msaRemark').val();
		$.urlAjaxData('manuscript/EditManuscript!returnToApp',data,function(){
		});
		BaseJs.toAction('manuscript/ListManuscript');
	}
}
function submitForm() {
//不是三审，没有设置上级审核人员的给出提示
	var auditId = $('#auditUserId').val();
	var level = ${manuscript.auditZt};
	if(level<3 && auditId=='null') {
		if(window.confirm('没有设置上级审核人员，确定提交吗')) {
			myform.submit();
		} 
	}
}
</script>
<style type="text/css">
#allReporters p {
	margin: 2px auto 1px 2px;
}
</style>
</head>
<body>
<h2 class="title">稿件信息</h2>
<s:form id="myform" action="manuscript/EditManuscript!audit">
	<s:hidden name="manuscript.id" />
	<s:hidden name="lhbdjzName" />
	<s:hidden name="lhbdjzId" />
	<table class="form">
		<tr>
			<th width="10%"><span class="hint">*</span>标题</th>
			<td width="25%"><s:textfield name="manuscript.title" cssClass="rule[required]" cssStyle="width:90%" /></td>
			<th width="10%"><span class="hint">*</span>是否急稿</th>
			<td width="15%"><s:radio list="#{ false:'否', true:'是'}" value="false" name="manuscript.urgent" /></td>
			<th width="10%"><span class="hint">*</span>所属栏目</th>
			<td width="15%"><m:select enumType="program.type" name="manuscript.column" /></td>
			<th width="15%" class="center">联合撰稿记者</th>
		</tr>
		<tr>
			<th><span class="hint">*</span>题材类别</th>
			<td><m:select enumType="submatter.typet" name="manuscript.owetype" /></td>
			<th><span class="hint">*</span>所属地域</th>
			<td><m:select enumType="region.type" name="manuscript.where" /></td>
			<th></th>
			<td></td>
			<td id="reporters"><s:hidden name="lhjz" /><select id="selectType" multiple="multiple" size="5">
				<optgroup label="记者列表">
					<s:iterator value="allRepUser">
						<option id="op${id}" value="${id }"><s:property value="name" /></option>
					</s:iterator>
				</optgroup>
			</select></td>
		</tr>
		<tr>
			<th>报道单位</th>
			<td><m:select enumType="newsFrom.type" name="manuscript.unit" /></td>
			<th>来源描述</th>
			<td colspan="3"><s:textfield name="manuscript.remark" cssStyle="width:200" /></td>
			<td rowspan="5" id="allReporters" style="vertical-align: top;"></td>
		</tr>
		<tr>
			<th>审核状态</th>
			<td><s:if test="manuscript.auditZt==1">一审中</s:if> <s:elseif test="manuscript.auditZt==2">二审中</s:elseif><s:elseif
				test="manuscript.auditZt==3">三审中</s:elseif></td>
			<th>关键字：(“,”隔开)</th>
			<td colspan="3"><s:textfield name="manuscript.tags" maxlength="255"></s:textfield></td>
		</tr>
		<tr>
			<th>历史审核记录</th>
			<td colspan="5"><s:iterator value="auditRecd">
				<s:if test="level==1">一审意见：</s:if>
				<s:elseif test="level==2">二审意见：</s:elseif>
				<s:elseif test="level==3">三审意见：</s:elseif>
				<s:property value="remark" />
				<br />
			</s:iterator></td>
		</tr>
		<tr>
			<th>稿件历史版本</th>
			<td colspan="3"><a
				href="<s:url action="manuscript/EditManuscript!viewRecod"/>?manuscript.id=<s:property value="manuscript.id"/>"
				target="_blank"> 查看稿件历史版本</a></td>
			<th>*设置上级审核人员</th>
			<td id="auditusers"><s:select id="auditUserId" list="users" name="manuscript.auditUser.id" label="审核人员列表" listKey="key"
				listValue="value" value="manuscript.auditUser.id" headerKey="-1" headerValue="--请选择--" ></s:select></td>
		</tr>
		<tr>
			<th>*审核意见</th>
			<td colspan="5"><s:textarea id="msaRemark" name="manuScAudit.remark"
				cssClass="rule[required] rule[length[0,250]]" /></td>
		</tr>
		<tr>
			<td colspan="6"><s:textarea name="manuscript.content" id="ctt" cssStyle="height: 500px;  width:  95%;"
				cssClass="rule[required]"></s:textarea></td>
			<td>
			<table width="100%">
				<tr>
					<td>相关图片</td>
				</tr>
				<tr>
					<td>
					<ul id="allImagesArea" style="margin: 0pt; padding: 0pt;">
						<s:iterator value="allimages">
							<li id="li${imageId}">
							<div style="position: relative">
							<div><a value="${imageId}" class="delimage" href="##">删除</a></div>
							<div>描述：${mark}</div>
							<a class="viewBig" title="新窗口中，查看大图"><img src="${path}" width="180px" /></a></div>
							</li>
						</s:iterator>
					</ul>
					</td>
				</tr>
			</table>
			</td>
		</tr>
	</table>

	<s:if test="manuscript.auditZt<=3">
		<div class="btnGroup"><input type="submit" id="submt" value="审核保存"/> <input name="subm" type="button"
			onClick="return killManuSc();" value="毙稿" /> <input name="subm" type="button" onClick="return returnToApp();"
			value="返回给撰稿人" /></div>
	</s:if>
</s:form>
</body>
</html>